package com.zr.share.down.controller;

import com.zr.share.enums.*;
import com.zr.share.down.model.pojo.PullDownVo;
import com.zr.utils.result.ResultBuilderUtil;
import com.zr.utils.result.ResultUtil;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName StatusController
 * @Description 状态公用数据
 * @Author Jiakui_Ma
 * @Date 2019/11/9 12:37
 */
@CrossOrigin
@RestController
@RequestMapping("metadata")
public class PullDownController {

    /*
     * @Author 马家奎
     * @Description 当前状态下拉列表
     * @Param
     * @return
     **/
    @PostMapping("getPullDownList")
    public ResultUtil getPullDownList(){
        //备件状态
        Map<String,List<PullDownVo>> satusMap = new HashMap<>();
        List<PullDownVo> pullDownVoList = new ArrayList<>();
        for (StatusEnum statusEnum : StatusEnum.values()) {
            pullDownVoList.add(new PullDownVo(statusEnum.getIndex(), statusEnum.getName()));
        }
        satusMap.put("status", pullDownVoList);
        //询价类型
        List<PullDownVo> inquiryTypeList = new ArrayList<>();
        for (InquiryEnum inquiryEnum : InquiryEnum.values()) {
            inquiryTypeList.add(new PullDownVo(inquiryEnum.getIndex(),inquiryEnum.getName()));
        }
        satusMap.put("type",inquiryTypeList);
        //询价状态
        List<PullDownVo> inquiryStatusList = new ArrayList<>();
        for (InquiryStatusEnum inquiryEnum : InquiryStatusEnum.values()) {
            inquiryStatusList.add(new PullDownVo(inquiryEnum.getIndex(),inquiryEnum.getName()));
        }
        satusMap.put("inquiryStatus",inquiryStatusList);
        //币别
        List<PullDownVo> inquiryCurrencyList = new ArrayList<>();
        for (InquiryCurrencyEnum inquiryCurrencyEnum : InquiryCurrencyEnum.values()) {
            inquiryCurrencyList.add(new PullDownVo(inquiryCurrencyEnum.getIndex(),inquiryCurrencyEnum.getName()));
        }
        satusMap.put("currencyCode",inquiryCurrencyList);
        //是否含税
        List<PullDownVo> isTaxList = new ArrayList<>();
        for (TaxEnum taxEnum : TaxEnum.values()) {
            isTaxList.add(new PullDownVo(taxEnum.getIndex(),taxEnum.getName()));
        }
        satusMap.put("isTax",isTaxList);
        return ResultBuilderUtil.success(satusMap);

    }
}
